package com.gusto.engine.clusterant.rmi.impl;

import java.util.ArrayList;
import java.util.List;

import com.gusto.engine.clusterant.algorithms.kmeansclustering.Cluster;
import com.gusto.engine.clusterant.algorithms.kmeansclustering.ClusterObject;
import com.gusto.engine.clusterant.algorithms.kmeansclustering.KMeansClustering;
import com.gusto.engine.clusterant.model.Point;
import com.gusto.engine.clusterant.rmi.KMeansClusteringRMI;

public class KMeansClusteringRMIImpl implements KMeansClusteringRMI {
	
	private KMeansClustering kmeansClustering;
	
	public KMeansClusteringRMIImpl(KMeansClustering kmeansClustering) {
		super();
		this.kmeansClustering = kmeansClustering;
	}
	
	public List<ClusterObject> cluster(List<Point> points) {
		List<ClusterObject> clusterObjectList = new ArrayList<ClusterObject>();
		List<Cluster> clusters = kmeansClustering.cluster(points);
		for (Cluster c : clusters) {
			clusterObjectList.add(new ClusterObject(c.getId(), c.getRow(), c.getCol(), c.getComponents()));
		}
		return clusterObjectList;
	}
	
}
